package l1j.server.server.clientpackets;

import l1j.server.echo.ClientThread;
import l1j.server.server.datatables.BuddyTable;
import l1j.server.server.model.Instance.L1PcInstance;

import java.util.logging.Level;
import java.util.logging.Logger;
// Referenced classes of package l1j.server.server.clientpackets:
// ClientBasePacket

/**
 * 處理收到由客戶端傳來刪除好友的封包
 */
public class C_DelBuddy extends ClientBasePacket {
	private static final Logger _log = Logger.getLogger(C_DelBuddy.class.getName());
	private static final String C_DEL_BUDDY = "[C] C_DelBuddy";

	@Override
	public String getType() {
		return C_DEL_BUDDY;
	}

	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);

		final L1PcInstance pc = client.getActiveChar();
		if (pc == null) {
			return;
		}
		final String charName = this.readS();
		if(charName == null){
			return;
		}
		BuddyTable.getInstance().removeBuddy(pc.getId(), charName);
		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}

}
